const app = getApp();
import ajaxRequset from './request.js';
 
/**
 * 请求api方法 集中管理
 * **/

module.exports = {
  /**
   * 登录
   * **/
  login(data) { return ajaxRequset({ url: '/API/PublicHandler.ashx?action=QuickLogin', data }).then(res => res) },

  /**
   * 获取折扣专区商品列表 、
   * 新人特惠 、
   * 拼团列表
   * **/ 
  getProductsList(data) { return ajaxRequset({ url: '/API/ProductHandler.ashx', data }).then(res => res) },

  /**
   * 今日特卖 、
   * 即将开售
   * **/
  gettodaydata(data) { return ajaxRequset({ url: '/API/ProductHandler.ashx?action=GetCategoryProducts', data }).then(res => res) },

  /**
   * 首页限时抢购 、
   * 抢购活动详情页
   * **/ 
  indexCountDown(data) { return ajaxRequset({ url: '/API/CountDownHandler.ashx', data }).then(res => res) },
  
  /**
   * 根据图片分类id获取图片
   * **/
  getImage(data) { return ajaxRequset({ url: '/API/ImageHandler.ashx?action=GetBanner', data }).then(res => res) },

  /**
   * 首页弹窗优惠券
   */
  getindexcoupon(data) { return ajaxRequset({ url:'/API/CouponsHandler.ashx?action=GetlogonCoupons'}).then(res=>res)},

  /**
   * 首页弹窗优惠券
   */
  getindexcoupon(data) { return ajaxRequset({ url:'/API/CouponsHandler.ashx?action=GetlogonCoupons'})},

  /**
   * 获得商品详情根据商品id
   * **/ 
  getGoodsDetail(data) { return ajaxRequset({ url: '/AppShop/AppShopHandler.ashx', data }).then(res => res) },
  
  /**
   * 获取优惠券中心分类
   */
  getcouponclassifyData(data) { return ajaxRequset({ url:'/API/CouponsHandler.ashx',data}).then(res=>res)},

  /**
  * 获取领券中心优惠券数据
  */
  getdataCouponsdata(data) { return ajaxRequset({ url:'/API/CouponsHandler.ashx',data}).then(res=>res)},

  /**
   *  用户领取优惠券
   */
  getcoupon(data) { return ajaxRequset({ url:"/API/CouponsHandler.ashx?action=UserGetCoupon",data}).then(res=>res)},
  /**
   * 添加商品到购物车
   * **/
  addToCart(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=addToCart', data }).then(res => res) },

   /**
    * 获取购物车列表
    * **/
  getCartList(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=getShoppingCartList', data }).then(res => res) },

  /**
   * 获取评论列表根据商品id
   * **/
  getReviewList(data) { return ajaxRequset({ url: '/API/ReviewHandler.ashx', data }).then(res => res) },

  /**
   * 获取商品实时用户下单列表
   * **/
  getShopUser(data) { return ajaxRequset({ url: '/api/VshopProcess.ashx', data }).then(res => res) },
  // 
  // 获取省市区 信息 列表
  getRegion(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=AddShippingAddress', data }).then(res => res) },

  /**
   * 领取优惠券
   * **/
  receiveCoupon(data) { return ajaxRequset({ url: '/API/CouponsHandler.ashx?action=UserGetCoupon', data }).then(res => res) },
  // 
  // 
  // 获取收货地址列表
  getAddressList(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=GetUserShippingAddress', data }).then(res => res) },

// modifyAddress
  modifyAddress(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=UpdateShippingAddress', data }).then(res => res) },
  // 
  // 
  // setdefaultAddress
  setdefaultAddress(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=SetDefaultShippingAddress', data }).then(res => res) },
  // 
  // 
  // deletedAddress
  deletedAddress(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=DelShippingAddress', data }).then(res => res) },
  /**
   * 从购物车移除商品
   * **/
  clearGoods(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=delCartItem', data }).then(res => res) },

  /**
   * 购物车商品数量修改
   * **/
  changeGoodsNum(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=ChageCartQuantity', data }).then(res => res) },

  /**
   * 获取订单信息
   * **/
  getOrderInfo(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=GetShoppingCart', data }).then(res => res) },

  /**
   * 提交订单
   * **/
  submitOrderInfo(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=SubmitOrder', data }).then(res => res) },

  /**
   * 支付
   * **/
  payOrder(data) { return ajaxRequset({ url: '/API/PublicHandler.ashx?action=GetPayParam', data }).then(res => res) },

  /**
   * 我的订单列表
   * **/
  getOrderList(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=OrderList', data }).then(res => res) },

  /**
   * 取消订单
   * **/
  cancelOrder(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=CloseOrder', data }).then(res => res) },

  /**
   * 订单详情
   * **/
  orderDetail(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=GetOrderDetail', data }).then(res => res) },

  /**
   * 分销下属
   * **/
  distributeSub(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=MySubMembers', data }).then(res => res) },

  /**
   * 获取代理级别列表
   * **/
  referralGrades(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=GetReferralGrades', data }).then(res => res) },

  /**
  * 获得首页商品分类
  * **/
  getGoodsSort(data) { return ajaxRequset({ url: '/AppShop/AppShopHandler.ashx?action=GetProductCategories', data }).then(res => res) },

  /**
  * 获得首页商品分类列表
  * **/
  getSortList(data) { return ajaxRequset({ url: '/api/ProductHandler.ashx?action=GetProducts', data }).then(res => res) },

  /**
  * 获得首页商品分类列表
  * **/
  getIntegralSort(data) { return ajaxRequset({ url: '/api/GiftCenterHandler.ashx?action=GetGiftCategoryList', data }).then(res => res) },

  /**
  * 获得积分商品列表
  * **/
  getIntegralList(data) { return ajaxRequset({ url: '/api/GiftCenterHandler.ashx?action=GetGiftList', data }).then(res => res) },

  /**
  * 获得礼品详情根据礼品Id
  * **/
  getGiftDetail(data) { return ajaxRequset({ url: '/api/GiftCenterHandler.ashx?action=GetGiftDetail', data }).then(res => res) },

  /**
  * 获取加密后的控价id
  * **/
  getKjId(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=GetEncryptkjid', data }).then(res => res) },

  /**
  * 根据控价id登录
  * **/
  kjLogin(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=KjAgentToLogin', data }).then(res => res) },

  /**
  * 获取小程序的unionid
  * **/
  getUnId(data) { return ajaxRequset({ url: '/API/WeChatAppletO2O.ashx?action=GetUserIdUnionId', data }).then(res => res) },

  /**
  * 根据unionid登录
  * **/
  unLogin(data) { return ajaxRequset({ url: '/API/WeChatAppletO2O.ashx?action=LoginByUnionId', data }).then(res => res) },

  /**
  * 获取用户信息
  * **/
  getUserInfo(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=GetMember', data }).then(res => res) },

  /**
  * 更新unionid
  * **/
  updateUnionid(data) { return ajaxRequset({ url: '/API/WeChatAppletO2O.ashx?action=UpdateUserUnionId', data }).then(res => res) },

  /**
  * 获取用户记录的unionId
  * **/
  getHistoryUnId(data) { return ajaxRequset({ url: '/API/WeChatAppletO2O.ashx?action=GetDataUnionId', data }).then(res => res) },

  /**
  * 签到
  * **/
  signIn(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=SignIn', data }).then(res => res) },

  /**
  * 签到
  * **/
  signIn(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=SignIn', data }).then(res => res) },

  /**
   * 个人信息编辑
   * **/
  editUserInfo(data) { return ajaxRequset({ type: 'POST', url: '/Api/MembersHandler.ashx?action=UpdateMemberInformation', data }).then(res => res) },

  /**
   * 获取消息列表
   * **/
  getMessages(data) { return ajaxRequset({ url: '/Api/MessageHandler.ashx?action=GetMessages', data }).then(res => res) },

  /**
   * 获取消息列表
   * **/
  getShare(data) { return ajaxRequset({ url: '/API/QrcodeHandler.ashx?action=GetQrcodeList', data }).then(res => res) },

  /**
   * 将信息设为已读
   * **/
  readMessage(data) { return ajaxRequset({ type: 'POST',  url: '/Api/MessageHandler.ashx?action=ReadMessage', data }).then(res => res) },

  /**
   * 删除消息
   * **/
  delMessa(data) { return ajaxRequset({ type: 'POST',  url: '/Api/MessageHandler.ashx?action=DelMessage', data }).then(res => res) },

  /**
   * 分享二维码
   * **/
  toShare(data) { return ajaxRequset({ url: '/API/QrcodeHandler.ashx?action=GetQrcodeList', data }).then(res => res) },

  /**
   * 扫码绑定临时关系接口
   * **/
  referral(data) { return ajaxRequset({ url: '/API/QrcodeHandler.ashx?action=BindTemReferral', data }).then(res => res) },

  /**
   * 订单调货
   * **/
  transferOrder(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=TransferOrder', data }).then(res => res) },

  /**
   * 快递公司信息列表
   * **/
  getExpressLis(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=GetExpressList', data }).then(res => res) },

  /**
   * 代理发货
   * **/
  sendOrder(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=SendOrder', data }).then(res => res) },

  /**
   * 获取代理申请状态
   * **/
  agentState(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=GetApplyAgentState', data }).then(res => res) },

  /**
   * 获取代理系统等级列表
   * **/
  agentData(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=GetKjAgentField', data }).then(res => res) },

  /**
   * 提交申请代理的请求表单
   * **/
  agentSubimt(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=ApplyKjAgent', data }).then(res => res) },

  /**
   * 确认收货
   * **/
  finishOrder(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=FinishOrder', data }).then(res => res) },

  /**
   * 申请分销员
   * **/
  applyReferral(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=ReferralRegister', data }).then(res => res) },

  /**
   * 获取分销员申请状态
   * **/
  getReferralStatus(data) { return ajaxRequset({ url: '/API/KjAgentHandler.ashx?action=GetReferralRegisterresults', data }).then(res => res) },  

  /**
   * 绑定代理账号
   * **/
  bindAgent(data) { return ajaxRequset({ type: 'POST', url: '/API/KjAgentHandler.ashx?action=BindAgent', data }).then(res => res) },

  /**
  * 获取热销产品
  * **/
  getTopProducts(data) { return ajaxRequset({ type: 'POST', url: '/API/ProductHandler.ashx?action=GetTopProducts', data }).then(res => res) },

  /**
  * 收藏商品
  * **/
  addFavorite(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=AddFavorite', data }).then(res => res) },

  /**
  * 取消商品收藏
  * **/
  delFavorite(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=DelFavorite', data }).then(res => res) },

  /**
  * 取消商品收藏
  * **/
  getFavorites(data) { return ajaxRequset({ url: '/API/MembersHandler.ashx?action=GetFavorites', data }).then(res => res) },

  /**
  * 取消商品收藏
  * **/
  submitReview(data) { return ajaxRequset({ type: 'POST', url: '/Api/OrdersHandler.ashx?action=SubmitReview', data }).then(res => res) },

  /**
  * 获取订单物流信息
  * **/
  getLogisticsInfo(data) { return ajaxRequset({ url: '/API/OrdersHandler.ashx?action=GetLogisticsInfo', data }).then(res => res) },

  /**
  * 获取积分记录
  * **/
  getPointRecordList(data) { return ajaxRequset({ url: '/Api/GiftCenterHandler.ashx?action=GetPointRecordList', data }).then(res => res) },

  /**
  * 申请退款
  * **/
  applyRefund(data) { return ajaxRequset({ type: 'POST', url: '/API/OrdersHandler.ashx?action=ApplyRefund', data }).then(res => res) },

  /**
  * 获取订单取消原因
  * **/
  getOrderClostReason(data) { return ajaxRequset({ type: 'POST', url: '/API/OrdersHandler.ashx?action=GetOrderClostReason', data }).then(res => res) },

  /**
  * 获取订单取消原因
  * **/
  getCommission(data) { return ajaxRequset({ url: '/Api/KjAgentHandler.ashx?action=MyReferral', data }).then(res => res) },

}